//
//  GengSuperMarketViewController.m
//  CommunitySupermarketProiect
//
//  Created by 吕惠卿 on 2017/11/14.
//  Copyright © 2017年 吕惠卿. All rights reserved.
//
#define NAVBAR_COLORCHANGE_POINT (-IMAGE_HEIGHT + NAV_HEIGHT)
#define NAV_HEIGHT 64
#define IMAGE_HEIGHT 200
#define SCROLL_DOWN_LIMIT 70
#define kScreenWidth [UIScreen mainScreen].bounds.size.width
#define kScreenHeight [UIScreen mainScreen].bounds.size.height
#define LIMIT_OFFSET_Y -(IMAGE_HEIGHT + SCROLL_DOWN_LIMIT)

#import "GengSuperMarketViewController.h"
#import "SDCycleScrollView.h"
#import "WRImageHelper.h"
#import "WRNavigationBar.h"
@interface GengSuperMarketViewController ()<UICollectionViewDelegate,UICollectionViewDataSource,UICollectionViewDelegateFlowLayout, SDCycleScrollViewDelegate>{
    RCSegmentView * rcs;
}
@property (nonatomic, strong)UICollectionView *collectionView;
@property (nonatomic, strong) SDCycleScrollView *advView;


@end
static NSString *homeeightColl = @"homeeightColl";
static NSString *homenineColl = @"homenineColl";


@implementation GengSuperMarketViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    WhiteColor;
    [self creatNavigationItem];
    self.automaticallyAdjustsScrollViewInsets = YES;
    AllSuperMarketViewController * First=[[AllSuperMarketViewController alloc]init];
    RecommendSuperMarketViewController * Second=[[RecommendSuperMarketViewController alloc]init];
    NSArray *controllers=@[First,Second];
    NSArray *titleArray =@[@"推荐商品",@"全部商品"];
    rcs  =[[RCSegmentView alloc]initWithFrame:CGRectMake(0, 264, WIDTH, HEIGHT-264) controllers:controllers titleArray:titleArray ParentController:self];
    [self.view addSubview:rcs];
    [self.view addSubview:self.advView];
}


-(void)creatNavigationItem{
    UIButton *btn = [UIButton new];
    [btn setImage:[UIImage imageNamed:@"返回"] forState:UIControlStateNormal];
    [btn addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
    [btn sizeToFit];
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:btn];
    UIButton *btnright = [UIButton new];
    [btnright setImage:[UIImage imageNamed:@"分类uu"] forState:UIControlStateNormal];
    [btnright addTarget:self action:@selector(btnrightClick) forControlEvents:UIControlEventTouchUpInside];
    [btnright sizeToFit];
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:btnright];
}
//分类
-(void)btnrightClick{
    ClassCommunitySupermarketViewController *classComVC = [[ClassCommunitySupermarketViewController alloc]init];
    [self.navigationController pushViewController:classComVC animated:YES];
}
- (void)btnClick:(id)sender {
    [self.navigationController popViewControllerAnimated:YES];
}
- (SDCycleScrollView *)advView
{
    if (_advView == nil) {
        NSArray *localImages = @[@"社区超市图",@"社区超市图",@"社区超市图",@"社区超市图",@"社区超市图",@"社区超市图",@"社区超市图"];
        _advView = [SDCycleScrollView cycleScrollViewWithFrame:CGRectMake(0, 64, kScreenWidth, IMAGE_HEIGHT) imageNamesGroup:localImages];
        _advView.pageDotColor = [UIColor grayColor];
        _advView.autoScrollTimeInterval = 2;
        _advView.currentPageDotColor = [UIColor whiteColor];
        _advView.bannerImageViewContentMode = UIViewContentModeScaleAspectFill;
    }
    return _advView;
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
@end
